package com.unei.groovy.batch

/**
 * Created by sunlei on 2015/1/14.
 */
class Money{
    int amount
    String currency

    Money(amountValue,currentcyValue){
        amount=amountValue
        currency=currentcyValue
    }

    boolean equals(Object other){
        if(null==other)return false
        if(!(other instanceof Money)) return false
        if(currency!=other.currency)return false
        if(amount!=other.amount)return false

        return true
    }

    int hashCode(){
        amount.hashCode()+currency.hashCode()
    }

    Money plus(Money other){
        if(null==other)return null
        if(other.currency!=currency){
            throw new IllegalArgumentException();
        }

        return new Money(amount+other.amount,currency)
    }
}

def buck=new Money(1,"USD")
buck=buck+buck
println(buck.getAmount())

